<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>网页广告效果动画实现</title>
  <style>
    .main{
      height: 2000px;
    }
    .main .img img{
      width: 300px;
      width: 300px;
      position: fixed;
      right: 0;
      bottom: 10px;
      display: none;
    }
    .us{
     
      border: 2px #3f00ff solid;
      text-align: center;
      background: yellow;
      border-radius: 50px;
      padding: 5px 10px;
      letter-spacing: 2px;
      font-weight: bold;
      margin: 50px auto;
    }
    .aa{
      position: relative;
       width: 100px;
       margin: 50px auto;
      text-align: center;
    }
    .aa img{
      position: absolute;
      left: -70px;
      top: 100px; 
      display: none;
    }
  </style>
</head>
<script src="js/jquery-1.12.4.min.js"></script>
<script>
  $(function(){
    $(window).scroll(function(){
      var distance = $(document).scrollTop();
      console.log('distance', distance);
      if(distance>=300){
        $('.msg').stop().slideDown(1000,function(){
        $('img').stop().fadeOut();
       setTimeout(() => {
          $('img').stop().fadeIn();
       }, 300);

        });
      }else{
         $('.msg').stop().slideUp(1000,function(){
         });
        
      }
    });
    $('.us').hover(function(){
      $('.add').stop().slideToggle(1000);
     
    });
  });
</script>
<body>
  <div class="main">
    <div class="img">
    <img class="msg" src="https://www.x6d.com/uploads/allimg/201223/1608729944859397.gif" alt="">
    </div>
    <div class="aa">
      <div class="us">关注我们</div>
      <img class="add" src="https://www.x6d.com/uploads/allimg/210129/1611906454496038.png" alt="">
    </div>
  </div>
</body>
</html>